package com.wanhe.base.model.disgn;

import android.text.TextUtils;

import com.orhanobut.logger.Logger;


/**
 *
 * @deprecated
 * Created by Administrator on 2016/5/19.
 */
public class ViewModel {

    public static final String TAG = "ViewModel";

    public static final double AUTO = -1;

    public static final int VIEW_TYPE_HIT = 0;
    public static final int VIEW_TYPE_PRICE0 = 1;
    public static final int VIEW_TYPE_PRICE1 = 2;
    public static final int VIEW_TYPE_PLUS = 3;
    public static final int VIEW_TYPE_NAME = 4;
    public static final int VIEW_TYPE_DESC = 5;
    public static final int VIEW_TYPE_CUST = 6;

    /**
     * left : -0.27943605122579407
     * top : -0.3289149694743871
     * width : 0.21022727272727273
     * height : 0.20454545454545456
     * color : #000
     * text : 海鲜贝贝郭
     */
    public String id;
    private double left;
    private double top;
    private String width;
    private double height;
    private String color;
    private String text;
    public int type;

    public String realTypeID;       //设计器拉出来的控件不一定是在菜品自己的菜类里面。所以这里需要记录所在真实的菜品分类
    public String realTypeID2;       //记录一个分类下有个页面的情况生成的特殊的ID


    private boolean visible;

    public boolean isVisiable() {
        return visible;
    }

    public void setVisiable(boolean visitable) {
        visible = visitable;
    }

    public double getLeft() {
        return this.left;
    }

    public void setLeft(double left) {
        this.left = left;
    }

    public double getTop() {
        return this.top;
    }

    public void setTop(double top) {
        this.top = top;
    }

    public double getWidth() {
        double width = 0;
        try{
            width = Double.parseDouble(this.width);
        } catch (Exception e){
            Logger.t(TAG).e(e.getMessage());
            width = -1;
        }
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public double getHeight() {
        return this.height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public String getColor() {
        String result = "#000000";
        Logger.i(TAG, "top：" + top);
        Logger.i(TAG, "left：" + left);
        Logger.i(TAG, "服务端得到的颜色值" + color);
        if (!TextUtils.isEmpty(color)) {
            if (!color.contains("#")){
                color = "#" + color;
            }
            color = color.substring(1, color.length());
            StringBuilder sb = new StringBuilder("#");
            for (int i = 0; i < color.length(); i++) {
                char colorValue = color.charAt(i);
                int colorHex = Integer.parseInt(String.valueOf(colorValue), 16);
                String colorHexStr = null;
                if (colorHex == 0) {
                    colorHexStr = "00";
                } else {
                    colorHex = colorHex * 17;
                    colorHexStr = Integer.toHexString(colorHex);
                }
                sb.append(colorHexStr);
            }
            result = sb.toString().toUpperCase();
        }
        Logger.i(TAG, "获取到的颜色值" + result);
        return result;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

}
